<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
	<meta charset="utf-8"> 
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=500" />
	<meta name="keywords" content="ScrollMagic, example, scrolling, attaching, scrollbar, removing, destroying, remove, destroy, free, resources" />
	<meta name="author"	content="Jan Paepke (www.janpaepke.de)" />
	<title>Removing & Destroying - Examples - ScrollMagic</title>

	<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,700,400italic|Josefin+Slab:400,700italic' rel='stylesheet' type='text/css'>
	<link rel="stylesheet" href="../../assets/css/normalize.css" type="text/css">
	<link rel="stylesheet" href="../../assets/css/style.css" type="text/css">
	<link rel="stylesheet" href="../../assets/css/examples.css" type="text/css">
	<link rel="shortcut icon" href="../../assets/img/favicon.ico" type="image/x-icon">

	<script type="text/javascript" src="../../assets/js/lib/jquery.min.js"></script>
	<script type="text/javascript" src="../../assets/js/lib/highlight.pack.js"></script>
	<script type="text/javascript" src="../../assets/js/lib/modernizr.custom.min.js"></script>
	<script type="text/javascript" src="../../assets/js/examples.js"></script>
	
	<script type="text/javascript" src="../../scrollmagic/uncompressed/ScrollMagic.js"></script>
	<script type="text/javascript" src="../../scrollmagic/uncompressed/plugins/debug.addIndicators.js"></script>
</head>
<body>
	<ul id="menu"></ul>
	<div id="content-wrapper">
		<div id="example-wrapper">
			<div class="scrollContent">
				<section id="titlechart">
					<div id="description">
						<h1>Removing & Destroying</h1>
						<h2>Free up some resources.</h2>
						<p>
							When you're done using ScrollMagic you might want to disrecard it to free up some resources. For this purpose both the ScrollMagic Controller and Scene posess a destroy method.<br>
							Remember to set all handlers to "<code>null</code>" so they are collected by the garbage collector.<br>
							For more information please refer to the <a href="../../docs/index.html">documentation</a>.
						</p>
						<a href="#" class="viewsource">view source</a>
					</div>
				</section>
				<section class="demo">
					<form class="move">
						<fieldset>
							<legend>Options</legend>
							<div>
								<input type="checkbox" id="destroyController" value="1" checked>
								<label for="destroyController">destroy Controller</label>
							</div>
							<div>
								<input type="checkbox" id="destroyScene" value="1" checked disabled>
								<label for="destroyScene">destroy Scene</label>
							</div>
							<div>
								<input type="checkbox" id="reset" value="1" checked>
								<label for="reset">reset</label>
							</div>
						</fieldset>
					</form>
					<div class="spacer s1"></div>
					<div id="trigger" class="spacer s1"></div>
					<div class="spacer s0"></div>
					<div id="destroybox" class="box1 blue">
						<a href="#" id="destroy">Kill me now!</a>
						<a href="#" class="viewsource">view source</a>
					</div>
					<div class="spacer s2"></div>
					<script>
						$(function () { // wait for document ready
							// init controller
							var controller = new ScrollMagic.Controller({loglevel: 3});

							// build scene
							var scene = new ScrollMagic.Scene({triggerElement: "#trigger", duration: 300, loglevel: 3})
											.setPin("#destroybox")
											.addIndicators() // add indicators (requires plugin)
											.addTo(controller);

						$("a#destroy").on("click", function (e) {
							e.preventDefault();
							if ($(this).hasClass("disabled")) {
								alert("Already removed. Please reload page to try again.");
								} else {
									$(this).addClass("disabled");
									var reset = $("#reset").prop("checked");
									if ($("#destroyController").prop("checked")) {
										controller.destroy(reset);
										controller = null;
									} else {
										scene.destroy(reset);
									}
									scene = null;
									tween = null;
								}
							});
						});
					</script>
				</section>
				<div class="spacer s_viewport"></div>
			</div>
		</div>
	</div>
	<script type="text/javascript" src="../../assets/js/tracking.js"></script>
</body>
</html>
